package org.codingq92.basic.thread;

public class SyncTest {

    static Integer cnt = 0;
    static final int LOOP = 280;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < LOOP; i++) {
                synchronized (cnt) {
                    cnt++;
                }
            }
        });
        thread.start();
        for (int i = 0; i < LOOP; i++) {
            synchronized (cnt) {
                cnt++;
            }
        }
        thread.join();
        System.out.println(cnt);
    }
}
